package builder;

import java.util.ArrayList;
import java.util.List;

class Product{
    private List<String> parts=new ArrayList<>();
    public void Add(String part){
        parts.add(part);
    }
    public void show(){
        for (String part:parts){
            System.out.println(part);
        }
    }
}
abstract class Builder{
    protected Product p;
    public Product GetProduct(){
        return this.p;
    }
    public abstract void BuildHead();
    public abstract void BuildNeck();
    public abstract void BuildBody();
    public abstract void BuildHand();
    public abstract void BuildFoot();
}
class ThinPerson extends Builder{
    public ThinPerson() {
        p=new Product();
    }

    @Override
    public void BuildHead() {
        p.Add("小头");
    }

    @Override
    public void BuildNeck() {
        p.Add("小脖子");
    }

    @Override
    public void BuildBody() {
        p.Add("小身板");
    }

    @Override
    public void BuildHand() {
        p.Add("小腿");
    }

    @Override
    public void BuildFoot() {
        p.Add("小脚");
    }
}
class FatPerson extends Builder{
    public FatPerson() {
        p=new Product();
    }

    @Override
    public void BuildHead() {
        p.Add("大头");
    }

    @Override
    public void BuildNeck() {
        p.Add("大脖子");
    }

    @Override
    public void BuildBody() {
        p.Add("大身板");
    }

    @Override
    public void BuildHand() {
        p.Add("大腿");
    }

    @Override
    public void BuildFoot() {
        p.Add("大脚");
    }
}

class Director{
    public void Construct(Builder builder){
        builder.BuildHead();
        builder.BuildNeck();
        builder.BuildBody();
        builder.BuildHand();
        builder.BuildFoot();
    }
}
public class Test {
    public static void main(String[] args) {
        Director director=new Director();
        Builder tp=new ThinPerson();
        Builder fp=new FatPerson();

        director.Construct(tp);
        Product p1=tp.GetProduct();
        p1.show();

        director.Construct(fp);
        Product p2=fp.GetProduct();
        p2.show();
    }
}
